Expand description

argmin-math provides mathematics related abstractions needed in argmin. It supports implementations of these abstractions for basic Vecs and for ndarray and nalgebra. The traits can of course also be implemented for your own types to make them compatible with argmin.

Usage

Add the following line to your dependencies list:

[dependencies]
argmin-math = "0.1.0"

This will activate the primitives and vec features. For other backends see the section below.

Features

Support for the various backends can be switched on via features:

FeatureDefaultBackend
primitivesyesbasic integer and floating point types
vecyesVecs (basic functionality)
ndarray_latestnondarray (latest supported version)
ndarray_latest-serdenondarray (latest supported version) + serde support
ndarray_v0_15nondarray (version 0.15)
ndarray_v0_15-serdenondarray (version 0.15) + serde support
ndarray_v0_14nondarray (version 0.14)
ndarray_v0_14-serdenondarray (version 0.14) + serde support
ndarray_v0_13nondarray (version 0.13)
ndarray_v0_13-serdenondarray (version 0.13) + serde support
nalgebra_latestnonalgebra (latest supported version)
nalgebra_latest-serdenonalgebra (latest supported version) + serde support
nalgebra_v0_31nonalgebra (version 0.31)
nalgebra_v0_31-serdenonalgebra (version 0.31) + serde support
nalgebra_v0_30nonalgebra (version 0.30)
nalgebra_v0_30-serdenonalgebra (version 0.30) + serde support
nalgebra_v0_29nonalgebra (version 0.29)
nalgebra_v0_29-serdenonalgebra (version 0.29) + serde support

It is not possible to activate two versions of the same backend.

The features labelled *latest* are an alias for the most recent supported version of the respective backend. It is however recommended to explicitly specify the desired version instead of using any of the *latest* features (see section about semantic versioning below).

Note that argmin by default compiles with serde support. Therefore, unless serde is deliberately turned off in argmin, it is necessary to activiate the serde support in argmin-math as well.

The default features primitives and vec can be turned off in order to only compile the trait definitions. If another backend is chosen, they will automatically be turned on again.

Using the ndarray_* features on Windows might require to explicitly choose the ndarray-linalg BLAS backend in the Cargo.toml (see the ndarray-linalg documentation for details):

ndarray-linalg = { version = "*", features = ["intel-mkl-static"] }

Example

Activate support for the latest supported ndarray version:

[dependencies]
argmin-math = { version = "0.1.0", features = ["ndarray_latest-serde"] }

Semantic versioning

This crate follows semantic versioning. Adding a new backend or a new version of a backend is not considered a breaking change. However, your code may still break if you use any of the features containing *latest*. It is therefore recommended to specify the actual version of the backend you are using.

Contributing

You found a bug? Your favourite backend is not supported? Feel free to open an issue or ideally submit a PR.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Traits

Add a T to self

Return the conjugate

(Pointwise) Divide a T by self

Dot/scalar product of T and self

Identity matrix

Compute the inverse (T) of self

Minimum and Maximum of type T

(Pointwise) Multiply a T with self

Compute the l2-norm (U) of self

Create a random number

Add a T scaled by an U to self

Subtract a T scaled by an U from self

Subtract a T from self

Return the transpose (U) of self

Dot/scalar product of T and self weighted by W (p^TWv)

Return param vector of all zeros (for now, this is a hack. It should be done better)

Zero for dynamically sized objects